package com.beiing.tianshuai.tianshuai.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.entity.PersonalDynamicBean;
import com.beiing.tianshuai.tianshuai.model.PersonalDynamicModel;
import com.beiing.tianshuai.tianshuai.model.PersonalDynamicModelImpl;
import com.beiing.tianshuai.tianshuai.view.PersonalDynamicViewImpl;

/**
 * Created by Jinni on 2017/7/20 0020.
 */

public class PersonalDynamicPresenter extends BasePresenter implements PersonalDynamicPresenterImpl, PersonalDynamicModel.OnRequestListener {

    private PersonalDynamicViewImpl mPersonalDynamicView;
    private PersonalDynamicModelImpl mPersonalDynamicModel;

    public PersonalDynamicPresenter(PersonalDynamicViewImpl personalDynamicView) {
        mPersonalDynamicView = personalDynamicView;
        mPersonalDynamicModel = new PersonalDynamicModel(this);
    }

    @Override
    public void getPersonalDynamicResult(String uid, String id, int lastItemNum, int pageSize) {
//        mPersonalDynamicView.showProgress();
        mPersonalDynamicModel.getPersonalDynamicResult(uid, id, lastItemNum, pageSize);
    }

    @Override
    public void setLikeState(String uid, String aid, String to_uid) {
        mPersonalDynamicModel.setLikeState(uid, aid, to_uid);
    }

    @Override
    public void deleteRelay(String uid, String idOne, int position) {
        mPersonalDynamicModel.deleteRelay(uid, idOne, position);
    }

    @Override
    public void deleteDynamic(String uid, String idOne, int position) {
        mPersonalDynamicModel.deleteDynamic(uid, idOne, position);
    }

    @Override
    public void onDelRelayResult(CommonBean bean) {
        mPersonalDynamicView.hideProgress();
        mPersonalDynamicView.getDelRelay(bean);
    }

    @Override
    public void onDelNormalResult(CommonBean bean) {
        mPersonalDynamicView.hideProgress();
        mPersonalDynamicView.getDelNormal(bean);
    }

    @Override
    public void onSuccess(PersonalDynamicBean bean) {
        mPersonalDynamicView.hideProgress();
        mPersonalDynamicView.onRequestSuccess(bean);
    }

    @Override
    public void onError(Throwable e) {
        mPersonalDynamicView.hideProgress();
        mPersonalDynamicView.onRequestFailed(e);
    }
}
